<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
    <title>Coverage for I:\CourseRegistration\student\views.py: 20%</title>
    <link rel="stylesheet" href="style.css" type="text/css">
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript" src="jquery.hotkeys.js"></script>
    <script type="text/javascript" src="jquery.isonscreen.js"></script>
    <script type="text/javascript" src="coverage_html.js"></script>
    <script type="text/javascript">
        jQuery(document).ready(coverage.pyfile_ready);
    </script>
</head>
<body class="pyfile">
<div id="header">
    <div class="content">
        <h1>Coverage for <b>I:\CourseRegistration\student\views.py</b> :
            <span class="pc_cov">20%</span>
        </h1>
        <img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
        <h2 class="stats">
            136 statements &nbsp;
            <span class="run shortkey_r button_toggle_run">27 run</span>
            <span class="mis show_mis shortkey_m button_toggle_mis">109 missing</span>
            <span class="exc show_exc shortkey_x button_toggle_exc">0 excluded</span>
        </h2>
    </div>
</div>
<div class="help_panel">
    <img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
    <p class="legend">Hot-keys on this page</p>
    <div>
    <p class="keyhelp">
        <span class="key">r</span>
        <span class="key">m</span>
        <span class="key">x</span>
        <span class="key">p</span> &nbsp; toggle line displays
    </p>
    <p class="keyhelp">
        <span class="key">j</span>
        <span class="key">k</span> &nbsp; next/prev highlighted chunk
    </p>
    <p class="keyhelp">
        <span class="key">0</span> &nbsp; (zero) top of page
    </p>
    <p class="keyhelp">
        <span class="key">1</span> &nbsp; (one) first highlighted chunk
    </p>
    </div>
</div>
<div id="source">
    <p id="t1" class="run"><span class="n"><a href="#t1">1</a></span><span class="t"><span class="key">from</span> <span class="op">.</span> <span class="key">import</span> <span class="nam">std</span>&nbsp;</span><span class="r"></span></p>
    <p id="t2" class="run"><span class="n"><a href="#t2">2</a></span><span class="t"><span class="key">from</span> <span class="nam">flask</span> <span class="key">import</span> <span class="nam">render_template</span><span class="op">,</span> <span class="nam">redirect</span><span class="op">,</span> <span class="nam">request</span><span class="op">,</span> <span class="nam">url_for</span><span class="op">,</span> <span class="nam">flash</span>&nbsp;</span><span class="r"></span></p>
    <p id="t3" class="run"><span class="n"><a href="#t3">3</a></span><span class="t"><span class="key">from</span> <span class="nam">flask_login</span> <span class="key">import</span> <span class="nam">login_required</span><span class="op">,</span> <span class="nam">current_user</span>&nbsp;</span><span class="r"></span></p>
    <p id="t4" class="run"><span class="n"><a href="#t4">4</a></span><span class="t"><span class="key">from</span> <span class="nam">models</span> <span class="key">import</span> <span class="nam">Student</span><span class="op">,</span> <span class="nam">Course</span><span class="op">,</span> <span class="nam">Takes</span><span class="op">,</span> <span class="nam">Inputbox</span><span class="op">,</span> <span class="nam">Prerequisite</span><span class="op">,</span> <span class="nam">Bill</span><span class="op">,</span> <span class="nam">Section</span><span class="op">,</span><span class="nam">Teaches</span>&nbsp;</span><span class="r"></span></p>
    <p id="t5" class="run"><span class="n"><a href="#t5">5</a></span><span class="t"><span class="key">import</span> <span class="nam">datetime</span>&nbsp;</span><span class="r"></span></p>
    <p id="t6" class="run"><span class="n"><a href="#t6">6</a></span><span class="t"><span class="key">from</span> <span class="nam">app</span> <span class="key">import</span> <span class="nam">db</span>&nbsp;</span><span class="r"></span></p>
    <p id="t7" class="run"><span class="n"><a href="#t7">7</a></span><span class="t"><span class="key">from</span> <span class="nam">student</span><span class="op">.</span><span class="nam">forms</span> <span class="key">import</span> <span class="nam">DepositForm</span>&nbsp;</span><span class="r"></span></p>
    <p id="t8" class="pln"><span class="n"><a href="#t8">8</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t9" class="pln"><span class="n"><a href="#t9">9</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t10" class="pln"><span class="n"><a href="#t10">10</a></span><span class="t"><span class="com"># TODO: &#27880;&#37322;&#35828;&#26126;&#20102;&#21738;&#20123;&#36335;&#30001;&#30340;query&#27809;&#26377;&#20889;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t11" class="pln"><span class="n"><a href="#t11">11</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t12" class="pln"><span class="n"><a href="#t12">12</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t13" class="run"><span class="n"><a href="#t13">13</a></span><span class="t"><span class="op">@</span><span class="nam">std</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/student-home'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t14" class="run"><span class="n"><a href="#t14">14</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t15" class="pln"><span class="n"><a href="#t15">15</a></span><span class="t"><span class="key">def</span> <span class="nam">student_home</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t16" class="pln"><span class="n"><a href="#t16">16</a></span><span class="t">    <span class="com"># student_home&#30028;&#38754;&#65292;&#35813;&#30028;&#38754;&#25552;&#20379;&#38142;&#25509;&#21040;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t17" class="pln"><span class="n"><a href="#t17">17</a></span><span class="t">    <span class="com"># 1. std.student_list_courses</span>&nbsp;</span><span class="r"></span></p>
    <p id="t18" class="pln"><span class="n"><a href="#t18">18</a></span><span class="t">    <span class="com"># 2. std.student_view_report_card</span>&nbsp;</span><span class="r"></span></p>
    <p id="t19" class="pln"><span class="n"><a href="#t19">19</a></span><span class="t">    <span class="com"># 3. std.student_input_box</span>&nbsp;</span><span class="r"></span></p>
    <p id="t20" class="pln"><span class="n"><a href="#t20">20</a></span><span class="t">    <span class="com"># 4. std.student_bill_information</span>&nbsp;</span><span class="r"></span></p>
    <p id="t21" class="pln"><span class="n"><a href="#t21">21</a></span><span class="t">    <span class="com"># &#26412;&#30028;&#38754;&#21482;&#25552;&#20379;&#20197;&#19978;&#22235;&#20010;&#36830;&#25509;&#65292;&#19981;&#36827;&#34892;&#25968;&#25454;&#24211;&#25805;&#20316;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t22" class="mis show_mis"><span class="n"><a href="#t22">22</a></span><span class="t">    <span class="nam">today</span> <span class="op">=</span> <span class="nam">datetime</span><span class="op">.</span><span class="nam">datetime</span><span class="op">.</span><span class="nam">today</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t23" class="mis show_mis"><span class="n"><a href="#t23">23</a></span><span class="t">    <span class="nam">name</span> <span class="op">=</span> <span class="nam">current_user</span><span class="op">.</span><span class="nam">get_name</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t24" class="mis show_mis"><span class="n"><a href="#t24">24</a></span><span class="t">    <span class="nam">greeting</span> <span class="op">=</span> <span class="nam">name</span> <span class="op">+</span> <span class="str">"&#21516;&#23398;&#65292;&#24744;&#22909;&#65281;&#29616;&#22312;&#26159;"</span> <span class="op">+</span> <span class="nam">str</span><span class="op">(</span><span class="nam">today</span><span class="op">.</span><span class="nam">year</span><span class="op">)</span> <span class="op">+</span> <span class="str">"&#24180;"</span> <span class="op">+</span> <span class="nam">str</span><span class="op">(</span><span class="nam">today</span><span class="op">.</span><span class="nam">month</span><span class="op">)</span> <span class="op">+</span> <span class="str">"&#26376;"</span> <span class="op">+</span> <span class="nam">str</span><span class="op">(</span><span class="nam">today</span><span class="op">.</span><span class="nam">day</span><span class="op">)</span> <span class="op">+</span> <span class="str">"&#26085;&#65292;"</span> <span class="op">+</span> <span class="nam">str</span><span class="op">(</span>&nbsp;</span><span class="r"></span></p>
    <p id="t25" class="pln"><span class="n"><a href="#t25">25</a></span><span class="t">        <span class="nam">today</span><span class="op">.</span><span class="nam">hour</span><span class="op">)</span> <span class="op">+</span> <span class="str">"&#26102;"</span> <span class="op">+</span> <span class="nam">str</span><span class="op">(</span>&nbsp;</span><span class="r"></span></p>
    <p id="t26" class="pln"><span class="n"><a href="#t26">26</a></span><span class="t">        <span class="nam">today</span><span class="op">.</span><span class="nam">minute</span><span class="op">)</span> <span class="op">+</span> <span class="str">"&#20998;"</span>&nbsp;</span><span class="r"></span></p>
    <p id="t27" class="pln"><span class="n"><a href="#t27">27</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t28" class="mis show_mis"><span class="n"><a href="#t28">28</a></span><span class="t">    <span class="nam">new_messages</span> <span class="op">=</span> <span class="nam">Inputbox</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Inputbox</span><span class="op">.</span><span class="nam">user_id</span> <span class="op">==</span> <span class="nam">current_user</span><span class="op">.</span><span class="nam">get_id</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span>&nbsp;</span><span class="r"></span></p>
    <p id="t29" class="pln"><span class="n"><a href="#t29">29</a></span><span class="t">        <span class="nam">Inputbox</span><span class="op">.</span><span class="nam">hasBeenRead</span> <span class="op">==</span> <span class="key">False</span><span class="op">)</span><span class="op">.</span><span class="nam">order_by</span><span class="op">(</span><span class="nam">Inputbox</span><span class="op">.</span><span class="nam">timestamp</span><span class="op">.</span><span class="nam">desc</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>  <span class="com"># &#26410;&#35835;&#28040;&#24687;(hasBeenRead&#20026;False)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t30" class="mis show_mis"><span class="n"><a href="#t30">30</a></span><span class="t">    <span class="key">if</span> <span class="nam">len</span><span class="op">(</span><span class="nam">new_messages</span><span class="op">)</span> <span class="op">></span> <span class="num">0</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t31" class="mis show_mis"><span class="n"><a href="#t31">31</a></span><span class="t">        <span class="nam">flash</span><span class="op">(</span><span class="str">'&#24744;&#26377;&#26032;&#30340;&#28040;&#24687;&#65292;&#35831;&#26597;&#30475;&#65281;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t32" class="mis show_mis"><span class="n"><a href="#t32">32</a></span><span class="t">    <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'student/student_home.html'</span><span class="op">,</span> <span class="nam">greeting</span><span class="op">=</span><span class="nam">greeting</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t33" class="pln"><span class="n"><a href="#t33">33</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t34" class="pln"><span class="n"><a href="#t34">34</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t35" class="run"><span class="n"><a href="#t35">35</a></span><span class="t"><span class="op">@</span><span class="nam">std</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/student-list-courses'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t36" class="run"><span class="n"><a href="#t36">36</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t37" class="pln"><span class="n"><a href="#t37">37</a></span><span class="t"><span class="key">def</span> <span class="nam">student_list_courses</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t38" class="pln"><span class="n"><a href="#t38">38</a></span><span class="t">    <span class="com"># &#26412;&#36335;&#30001;&#26159;&#21015;&#20986;&#35838;&#31243;&#30028;&#38754;&#65292;&#26597;&#35810;&#20986;&#23398;&#29983;&#30340;&#21487;&#36873;&#35838;&#31243;&#21644;&#24050;&#36873;&#35838;&#31243;&#65292;&#36820;&#22238;&#36825;&#20123;&#35838;&#31243;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t39" class="pln"><span class="n"><a href="#t39">39</a></span><span class="t">    <span class="com"># &#20854;&#20013;&#21487;&#36873;&#35838;&#31243;&#20026;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t40" class="pln"><span class="n"><a href="#t40">40</a></span><span class="t">    <span class="com"># 1. &#26412;&#23398;&#26399;&#24320;&#35774;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t41" class="pln"><span class="n"><a href="#t41">41</a></span><span class="t">    <span class="com"># 2. &#26377;&#32769;&#24072;&#25945;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t42" class="pln"><span class="n"><a href="#t42">42</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t43" class="pln"><span class="n"><a href="#t43">43</a></span><span class="t">    <span class="com"># &#36825;&#37324;&#19981;&#32771;&#34385;&#35813;&#35838;&#31243;&#23481;&#37327;&#26159;&#21542;&#24050;&#28385;&#65292;&#36825;&#22312;std.student_register_for_course&#36335;&#30001;&#22788;&#29702;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t44" class="pln"><span class="n"><a href="#t44">44</a></span><span class="t">    <span class="com"># &#26412;&#36335;&#30001;&#20165;&#26597;&#35810;&#20986;&#36825;&#20123;&#35838;&#31243;&#65292;&#20256;&#36865;&#21040;&#21069;&#31471;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t45" class="mis show_mis"><span class="n"><a href="#t45">45</a></span><span class="t">    <span class="nam">today</span> <span class="op">=</span> <span class="nam">datetime</span><span class="op">.</span><span class="nam">datetime</span><span class="op">.</span><span class="nam">today</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t46" class="mis show_mis"><span class="n"><a href="#t46">46</a></span><span class="t">    <span class="nam">thisSemester</span> <span class="op">=</span> <span class="nam">str</span><span class="op">(</span><span class="nam">today</span><span class="op">.</span><span class="nam">year</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t47" class="mis show_mis"><span class="n"><a href="#t47">47</a></span><span class="t">    <span class="key">if</span> <span class="nam">int</span><span class="op">(</span><span class="nam">today</span><span class="op">.</span><span class="nam">month</span><span class="op">)</span> <span class="op">&lt;</span> <span class="num">7</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t48" class="mis show_mis"><span class="n"><a href="#t48">48</a></span><span class="t">        <span class="nam">thisSemester</span> <span class="op">+=</span> <span class="str">"1"</span>&nbsp;</span><span class="r"></span></p>
    <p id="t49" class="pln"><span class="n"><a href="#t49">49</a></span><span class="t">    <span class="key">else</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t50" class="mis show_mis"><span class="n"><a href="#t50">50</a></span><span class="t">        <span class="nam">thisSemester</span> <span class="op">+=</span> <span class="str">"2"</span>&nbsp;</span><span class="r"></span></p>
    <p id="t51" class="pln"><span class="n"><a href="#t51">51</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t52" class="mis show_mis"><span class="n"><a href="#t52">52</a></span><span class="t">    <span class="nam">take_list</span><span class="op">=</span> <span class="nam">Takes</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Takes</span><span class="op">.</span><span class="nam">student_id</span><span class="op">==</span><span class="nam">current_user</span><span class="op">.</span><span class="nam">get_id</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t53" class="mis show_mis"><span class="n"><a href="#t53">53</a></span><span class="t">    <span class="nam">teaches_list</span><span class="op">=</span><span class="nam">Teaches</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t54" class="pln"><span class="n"><a href="#t54">54</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t55" class="mis show_mis"><span class="n"><a href="#t55">55</a></span><span class="t">    <span class="nam">section_id_has_teaches</span> <span class="op">=</span> <span class="op">[</span><span class="nam">t</span><span class="op">.</span><span class="nam">section_id</span> <span class="key">for</span> <span class="nam">t</span> <span class="key">in</span> <span class="nam">teaches_list</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t56" class="mis show_mis"><span class="n"><a href="#t56">56</a></span><span class="t">    <span class="nam">section_id_has_choose</span> <span class="op">=</span> <span class="op">[</span><span class="nam">t</span><span class="op">.</span><span class="nam">section_id</span> <span class="key">for</span> <span class="nam">t</span> <span class="key">in</span> <span class="nam">take_list</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t57" class="mis show_mis"><span class="n"><a href="#t57">57</a></span><span class="t">    <span class="nam">thisSemester_section_list</span> <span class="op">=</span> <span class="nam">Section</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Section</span><span class="op">.</span><span class="nam">semester</span> <span class="op">==</span> <span class="nam">thisSemester</span><span class="op">)</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t58" class="mis show_mis"><span class="n"><a href="#t58">58</a></span><span class="t">    <span class="nam">section_list</span><span class="op">=</span><span class="op">[</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t59" class="mis show_mis"><span class="n"><a href="#t59">59</a></span><span class="t">    <span class="key">for</span> <span class="nam">s</span> <span class="key">in</span> <span class="nam">thisSemester_section_list</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t60" class="mis show_mis"><span class="n"><a href="#t60">60</a></span><span class="t">        <span class="key">if</span> <span class="nam">s</span><span class="op">.</span><span class="nam">section_id</span> <span class="key">not</span> <span class="key">in</span> <span class="nam">section_id_has_choose</span> <span class="key">and</span> <span class="nam">s</span><span class="op">.</span><span class="nam">section_id</span> <span class="key">in</span> <span class="nam">section_id_has_teaches</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t61" class="mis show_mis"><span class="n"><a href="#t61">61</a></span><span class="t">            <span class="nam">section_list</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">s</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t62" class="pln"><span class="n"><a href="#t62">62</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t63" class="pln"><span class="n"><a href="#t63">63</a></span><span class="t">    <span class="com"># &#30456;&#21516;&#65292;&#20294;&#26159;&#23398;&#26399;&#19981;&#21516;&#30340;&#35838;&#31243;&#65292;&#25152;&#20197;&#36825;&#37324;&#38656;&#35201;&#26597;&#21040;&#30340;&#26159;section</span>&nbsp;</span><span class="r"></span></p>
    <p id="t64" class="pln"><span class="n"><a href="#t64">64</a></span><span class="t">    <span class="com"># &#34920;&#20013;&#22312;&#24403;&#21069;&#23398;&#26399;&#24320;&#35838;&#30340;&#25968;&#25454;&#39033;&#65292;section&#34920;&#20013;&#23450;&#20041;&#20102;course&#30340;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t65" class="pln"><span class="n"><a href="#t65">65</a></span><span class="t">    <span class="com"># &#20851;&#31995;&#24341;&#29992;&#65292;&#21487;&#20197;&#30452;&#25509;&#24471;&#21040;&#20182;&#25152;&#23545;&#24212;&#30340;course&#23545;&#35937;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t66" class="pln"><span class="n"><a href="#t66">66</a></span><span class="t">    <span class="com"># &#20877;&#21015;&#20986;&#26412;&#23398;&#26399;&#24050;&#36873;&#25321;&#30340;&#35838;&#31243;&#65292;&#21487;&#20379;&#36864;&#36873;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t67" class="mis show_mis"><span class="n"><a href="#t67">67</a></span><span class="t">    <span class="nam">taken_course_list</span> <span class="op">=</span> <span class="nam">Takes</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Takes</span><span class="op">.</span><span class="nam">student_id</span> <span class="op">==</span> <span class="nam">current_user</span><span class="op">.</span><span class="nam">get_id</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="nam">Takes</span><span class="op">.</span><span class="nam">isPrimary</span> <span class="op">==</span> <span class="key">True</span><span class="op">)</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t68" class="mis show_mis"><span class="n"><a href="#t68">68</a></span><span class="t">    <span class="nam">alternative_course_list</span> <span class="op">=</span> <span class="nam">Takes</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Takes</span><span class="op">.</span><span class="nam">student_id</span> <span class="op">==</span> <span class="nam">current_user</span><span class="op">.</span><span class="nam">get_id</span><span class="op">(</span><span class="op">)</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t69" class="pln"><span class="n"><a href="#t69">69</a></span><span class="t">                                                 <span class="nam">Takes</span><span class="op">.</span><span class="nam">isPrimary</span> <span class="op">==</span> <span class="key">False</span><span class="op">)</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t70" class="mis show_mis"><span class="n"><a href="#t70">70</a></span><span class="t">    <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'student/student_list_courses.html'</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t71" class="pln"><span class="n"><a href="#t71">71</a></span><span class="t">                           <span class="nam">section_list</span><span class="op">=</span><span class="nam">section_list</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t72" class="pln"><span class="n"><a href="#t72">72</a></span><span class="t">                           <span class="nam">taken_course_list</span><span class="op">=</span><span class="nam">taken_course_list</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t73" class="pln"><span class="n"><a href="#t73">73</a></span><span class="t">                           <span class="nam">alternative_course_list</span><span class="op">=</span><span class="nam">alternative_course_list</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t74" class="pln"><span class="n"><a href="#t74">74</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t75" class="pln"><span class="n"><a href="#t75">75</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t76" class="pln"><span class="n"><a href="#t76">76</a></span><span class="t"><span class="com"># &#26412;&#36335;&#30001;&#20165;&#22788;&#29702;&#25968;&#25454;&#65292;&#27809;&#26377;&#23454;&#38469;&#30028;&#38754;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t77" class="run"><span class="n"><a href="#t77">77</a></span><span class="t"><span class="op">@</span><span class="nam">std</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/student-register-for-course/&lt;int:section_id>/&lt;isPrimary>'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t78" class="run"><span class="n"><a href="#t78">78</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t79" class="pln"><span class="n"><a href="#t79">79</a></span><span class="t"><span class="key">def</span> <span class="nam">student_register_for_course</span><span class="op">(</span><span class="nam">section_id</span><span class="op">,</span> <span class="nam">isPrimary</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t80" class="mis show_mis"><span class="n"><a href="#t80">80</a></span><span class="t">    <span class="key">if</span> <span class="nam">isPrimary</span><span class="op">==</span><span class="str">"True"</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t81" class="mis show_mis"><span class="n"><a href="#t81">81</a></span><span class="t">        <span class="nam">isPrimary</span><span class="op">=</span><span class="key">True</span>&nbsp;</span><span class="r"></span></p>
    <p id="t82" class="pln"><span class="n"><a href="#t82">82</a></span><span class="t">    <span class="key">else</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t83" class="mis show_mis"><span class="n"><a href="#t83">83</a></span><span class="t">        <span class="nam">isPrimary</span><span class="op">=</span><span class="key">False</span>&nbsp;</span><span class="r"></span></p>
    <p id="t84" class="pln"><span class="n"><a href="#t84">84</a></span><span class="t">    <span class="com"># &#26412;&#36335;&#30001;&#35299;&#20915;&#23398;&#29983;&#36873;&#35838;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t85" class="pln"><span class="n"><a href="#t85">85</a></span><span class="t">    <span class="com"># &#26412;&#36335;&#30001;&#25509;&#21463;course_id&#21644;isPrimary&#20004;&#20010;&#21442;&#25968;&#65292;&#29992;&#20197;&#20915;&#23450;&#35201;&#36873;&#30340;&#35838;&#31243;&#20197;&#21450;&#26159;&#21542;&#20026;primary</span>&nbsp;</span><span class="r"></span></p>
    <p id="t86" class="mis show_mis"><span class="n"><a href="#t86">86</a></span><span class="t">    <span class="nam">section</span> <span class="op">=</span> <span class="nam">Section</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Section</span><span class="op">.</span><span class="nam">section_id</span> <span class="op">==</span> <span class="nam">section_id</span><span class="op">)</span><span class="op">.</span><span class="nam">first</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t87" class="mis show_mis"><span class="n"><a href="#t87">87</a></span><span class="t">    <span class="nam">course_id</span> <span class="op">=</span> <span class="nam">section</span><span class="op">.</span><span class="nam">course_id</span>&nbsp;</span><span class="r"></span></p>
    <p id="t88" class="mis show_mis"><span class="n"><a href="#t88">88</a></span><span class="t">    <span class="nam">prerequisites_all</span> <span class="op">=</span> <span class="nam">Prerequisite</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Prerequisite</span><span class="op">.</span><span class="nam">course_id</span> <span class="op">==</span> <span class="nam">course_id</span><span class="op">)</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t89" class="pln"><span class="n"><a href="#t89">89</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t90" class="mis show_mis"><span class="n"><a href="#t90">90</a></span><span class="t">    <span class="nam">takes</span><span class="op">=</span><span class="nam">Takes</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Takes</span><span class="op">.</span><span class="nam">student_id</span><span class="op">==</span><span class="nam">current_user</span><span class="op">.</span><span class="nam">get_id</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Takes</span><span class="op">.</span><span class="nam">isPrimary</span><span class="op">==</span><span class="key">True</span><span class="op">)</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t91" class="mis show_mis"><span class="n"><a href="#t91">91</a></span><span class="t">    <span class="nam">hasTakesCourse_id</span><span class="op">=</span><span class="op">[</span><span class="nam">t</span><span class="op">.</span><span class="nam">course_id</span> <span class="key">for</span> <span class="nam">t</span> <span class="key">in</span> <span class="nam">takes</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t92" class="pln"><span class="n"><a href="#t92">92</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t93" class="mis show_mis"><span class="n"><a href="#t93">93</a></span><span class="t">    <span class="nam">print</span><span class="op">(</span><span class="nam">hasTakesCourse_id</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t94" class="mis show_mis"><span class="n"><a href="#t94">94</a></span><span class="t">    <span class="nam">prerequisites</span><span class="op">=</span><span class="op">[</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t95" class="mis show_mis"><span class="n"><a href="#t95">95</a></span><span class="t">    <span class="key">for</span> <span class="nam">p</span> <span class="key">in</span> <span class="nam">prerequisites_all</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t96" class="mis show_mis"><span class="n"><a href="#t96">96</a></span><span class="t">        <span class="key">if</span> <span class="nam">p</span><span class="op">.</span><span class="nam">pre_id</span> <span class="key">not</span> <span class="key">in</span> <span class="nam">hasTakesCourse_id</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t97" class="mis show_mis"><span class="n"><a href="#t97">97</a></span><span class="t">            <span class="nam">prerequisites</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">p</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t98" class="pln"><span class="n"><a href="#t98">98</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t99" class="mis show_mis"><span class="n"><a href="#t99">99</a></span><span class="t">    <span class="nam">today</span> <span class="op">=</span> <span class="nam">datetime</span><span class="op">.</span><span class="nam">datetime</span><span class="op">.</span><span class="nam">today</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t100" class="mis show_mis"><span class="n"><a href="#t100">100</a></span><span class="t">    <span class="nam">thisSemester</span> <span class="op">=</span> <span class="nam">str</span><span class="op">(</span><span class="nam">today</span><span class="op">.</span><span class="nam">year</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t101" class="mis show_mis"><span class="n"><a href="#t101">101</a></span><span class="t">    <span class="key">if</span> <span class="nam">int</span><span class="op">(</span><span class="nam">today</span><span class="op">.</span><span class="nam">month</span><span class="op">)</span> <span class="op">&lt;</span> <span class="num">7</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t102" class="mis show_mis"><span class="n"><a href="#t102">102</a></span><span class="t">        <span class="nam">thisSemester</span> <span class="op">+=</span> <span class="str">"1"</span>&nbsp;</span><span class="r"></span></p>
    <p id="t103" class="pln"><span class="n"><a href="#t103">103</a></span><span class="t">    <span class="key">else</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t104" class="mis show_mis"><span class="n"><a href="#t104">104</a></span><span class="t">        <span class="nam">thisSemester</span> <span class="op">+=</span> <span class="str">"2"</span>&nbsp;</span><span class="r"></span></p>
    <p id="t105" class="mis show_mis"><span class="n"><a href="#t105">105</a></span><span class="t">    <span class="nam">section</span><span class="op">=</span><span class="nam">Section</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">section</span><span class="op">.</span><span class="nam">semester</span><span class="op">==</span><span class="nam">thisSemester</span><span class="op">)</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t106" class="mis show_mis"><span class="n"><a href="#t106">106</a></span><span class="t">    <span class="nam">thisSemesterCourse_id</span><span class="op">=</span><span class="op">[</span><span class="nam">s</span><span class="op">.</span><span class="nam">course_id</span> <span class="key">for</span> <span class="nam">s</span> <span class="key">in</span> <span class="nam">section</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t107" class="mis show_mis"><span class="n"><a href="#t107">107</a></span><span class="t">    <span class="nam">prerequisitesNoThisSemester</span><span class="op">=</span><span class="op">[</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t108" class="mis show_mis"><span class="n"><a href="#t108">108</a></span><span class="t">    <span class="key">for</span> <span class="nam">p</span> <span class="key">in</span> <span class="nam">prerequisites</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t109" class="mis show_mis"><span class="n"><a href="#t109">109</a></span><span class="t">        <span class="key">if</span> <span class="nam">p</span><span class="op">.</span><span class="nam">pre_id</span> <span class="key">not</span> <span class="key">in</span> <span class="nam">thisSemesterCourse_id</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t110" class="mis show_mis"><span class="n"><a href="#t110">110</a></span><span class="t">            <span class="nam">prerequisitesNoThisSemester</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">p</span><span class="op">.</span><span class="nam">pre_id</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t111" class="pln"><span class="n"><a href="#t111">111</a></span><span class="t">    <span class="com"># &#39318;&#20808;&#26597;&#35810;&#26412;&#35838;&#31243;&#26159;&#21542;&#26377;&#36824;&#26410;&#20462;&#30340;&#20808;&#20462;&#35838;&#65292;&#22914;&#26524;&#26377;&#65292;&#37027;&#20040;&#36873;&#35838;&#22833;&#36133;&#65292;&#21017;&#36716;&#21040;student_list_prerequisites.html, &#22312;&#36825;&#20010;&#39029;&#38754;&#21015;&#20986;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t112" class="pln"><span class="n"><a href="#t112">112</a></span><span class="t">    <span class="com"># &#36825;&#20123;&#20808;&#20462;&#35838;&#65307;&#36825;&#20010;&#39029;&#38754;&#36824;&#25552;&#20379;&#38142;&#25509;&#36820;&#22238;&#21040;&#19978;&#19968;&#20010;&#36335;&#30001;&#65292;&#20063;&#23601;&#26159;std.student_list_courses</span>&nbsp;</span><span class="r"></span></p>
    <p id="t113" class="pln"><span class="n"><a href="#t113">113</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t114" class="mis show_mis"><span class="n"><a href="#t114">114</a></span><span class="t">    <span class="key">if</span> <span class="nam">len</span><span class="op">(</span><span class="nam">prerequisites</span><span class="op">)</span><span class="op">></span><span class="num">0</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t115" class="mis show_mis"><span class="n"><a href="#t115">115</a></span><span class="t">        <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'student/student_list_prerequisites.html'</span><span class="op">,</span> <span class="nam">prerequisites</span><span class="op">=</span><span class="nam">prerequisites</span><span class="op">,</span><span class="nam">prerequisitesNoThisSemeter</span><span class="op">=</span><span class="nam">prerequisitesNoThisSemester</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t116" class="pln"><span class="n"><a href="#t116">116</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t117" class="pln"><span class="n"><a href="#t117">117</a></span><span class="t">    <span class="com"># &#21040;&#36825;&#37324;&#65292;&#20808;&#20462;&#35838;&#20026;&#31354;&#25110;&#32773;&#24050;&#32463;&#20462;&#36807;&#20102;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t118" class="pln"><span class="n"><a href="#t118">118</a></span><span class="t">    <span class="com"># &#28982;&#21518;&#26597;&#30475;&#35838;&#31243;&#23481;&#37327;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t119" class="pln"><span class="n"><a href="#t119">119</a></span><span class="t">    <span class="com"># &#22914;&#26524;&#28385;&#36275;&#36873;&#35838;&#26465;&#20214;&#65292;&#21363;&#36873;&#36825;&#20010;&#35838;&#30340;&#20154;&#25968;&#20026;10&#20154;&#19968;&#19979;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t120" class="pln"><span class="n"><a href="#t120">120</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t121" class="pln"><span class="n"><a href="#t121">121</a></span><span class="t">    <span class="com"># TODO: &#36825;&#37324;&#38656;&#35201;&#30830;&#23450;isPrimary&#65292;&#22914;&#26524;&#23481;&#37327;&#24050;&#28385;&#65292;&#26159;&#21542;&#35813;&#35838;&#36824;&#33021;&#20316;&#20026;&#20854;&#22791;&#36873;&#35838;&#65311;&#65311;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t122" class="mis show_mis"><span class="n"><a href="#t122">122</a></span><span class="t">    <span class="nam">count</span> <span class="op">=</span> <span class="nam">len</span><span class="op">(</span><span class="nam">Takes</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Takes</span><span class="op">.</span><span class="nam">isPrimary</span> <span class="key">and</span> <span class="nam">Takes</span><span class="op">.</span><span class="nam">section_id</span> <span class="op">==</span> <span class="nam">section_id</span><span class="op">)</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t123" class="mis show_mis"><span class="n"><a href="#t123">123</a></span><span class="t">    <span class="key">if</span> <span class="nam">count</span> <span class="op">&lt;</span> <span class="num">10</span><span class="op">:</span>  <span class="com"># &#36873;&#35838;&#23481;&#37327;&#26410;&#28385;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t124" class="mis show_mis"><span class="n"><a href="#t124">124</a></span><span class="t">        <span class="nam">takes</span> <span class="op">=</span> <span class="nam">Takes</span><span class="op">(</span><span class="nam">student_id</span><span class="op">=</span><span class="nam">current_user</span><span class="op">.</span><span class="nam">get_id</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="nam">section_id</span><span class="op">=</span><span class="nam">section_id</span><span class="op">,</span> <span class="nam">course_id</span><span class="op">=</span><span class="nam">course_id</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t125" class="pln"><span class="n"><a href="#t125">125</a></span><span class="t">                      <span class="nam">isPrimary</span><span class="op">=</span><span class="nam">isPrimary</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t126" class="mis show_mis"><span class="n"><a href="#t126">126</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">add</span><span class="op">(</span><span class="nam">takes</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t127" class="mis show_mis"><span class="n"><a href="#t127">127</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">commit</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t128" class="pln"><span class="n"><a href="#t128">128</a></span><span class="t">    <span class="key">else</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t129" class="mis show_mis"><span class="n"><a href="#t129">129</a></span><span class="t">        <span class="key">if</span> <span class="key">not</span> <span class="nam">isPrimary</span><span class="op">:</span>  <span class="com"># &#36873;&#35838;&#23481;&#37327;&#24050;&#28385;&#65292;&#21487;&#20197;&#35774;&#32622;&#20026;&#22791;&#36873;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t130" class="mis show_mis"><span class="n"><a href="#t130">130</a></span><span class="t">            <span class="nam">takes</span> <span class="op">=</span> <span class="nam">Takes</span><span class="op">(</span><span class="nam">student_id</span><span class="op">=</span><span class="nam">current_user</span><span class="op">.</span><span class="nam">get_id</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="nam">section_id</span><span class="op">=</span><span class="nam">section_id</span><span class="op">,</span> <span class="nam">course_id</span><span class="op">=</span><span class="nam">course_id</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t131" class="pln"><span class="n"><a href="#t131">131</a></span><span class="t">                          <span class="nam">isPrimary</span><span class="op">=</span><span class="nam">isPrimary</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t132" class="mis show_mis"><span class="n"><a href="#t132">132</a></span><span class="t">            <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">add</span><span class="op">(</span><span class="nam">takes</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t133" class="mis show_mis"><span class="n"><a href="#t133">133</a></span><span class="t">            <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">commit</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t134" class="pln"><span class="n"><a href="#t134">134</a></span><span class="t">    <span class="com"># &#21542;&#21017;&#65292;&#19981;&#33021;&#36873;&#35838;&#65292;&#36820;&#22238;&#21040;std.student_list_courses</span>&nbsp;</span><span class="r"></span></p>
    <p id="t135" class="pln"><span class="n"><a href="#t135">135</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t136" class="mis show_mis"><span class="n"><a href="#t136">136</a></span><span class="t">    <span class="key">return</span> <span class="nam">redirect</span><span class="op">(</span><span class="nam">url_for</span><span class="op">(</span><span class="str">'std.student_list_courses'</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t137" class="pln"><span class="n"><a href="#t137">137</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t138" class="pln"><span class="n"><a href="#t138">138</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t139" class="run"><span class="n"><a href="#t139">139</a></span><span class="t"><span class="op">@</span><span class="nam">std</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/student-cancel-course/&lt;int:section_id>/&lt;isPrimary>'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t140" class="run"><span class="n"><a href="#t140">140</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t141" class="pln"><span class="n"><a href="#t141">141</a></span><span class="t"><span class="key">def</span> <span class="nam">student_cancel_course</span><span class="op">(</span><span class="nam">section_id</span><span class="op">,</span> <span class="nam">isPrimary</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t142" class="pln"><span class="n"><a href="#t142">142</a></span><span class="t">    <span class="com"># &#26412;&#36335;&#30001;&#35299;&#20915;&#36864;&#35838;&#65292;&#21253;&#25324;&#21462;&#28040;&#24050;&#36873;&#35838;&#31243;&#21644;&#24050;&#20316;&#20026;&#22791;&#36873;&#30340;&#35838;&#31243;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t143" class="mis show_mis"><span class="n"><a href="#t143">143</a></span><span class="t">    <span class="nam">take</span> <span class="op">=</span> <span class="nam">Takes</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Takes</span><span class="op">.</span><span class="nam">section_id</span> <span class="op">==</span> <span class="nam">section_id</span><span class="op">)</span><span class="op">.</span><span class="nam">first</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t144" class="mis show_mis"><span class="n"><a href="#t144">144</a></span><span class="t">    <span class="key">if</span> <span class="nam">take</span> <span class="key">is</span> <span class="key">not</span> <span class="key">None</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t145" class="mis show_mis"><span class="n"><a href="#t145">145</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">delete</span><span class="op">(</span><span class="nam">take</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t146" class="mis show_mis"><span class="n"><a href="#t146">146</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">commit</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t147" class="mis show_mis"><span class="n"><a href="#t147">147</a></span><span class="t">        <span class="key">if</span> <span class="nam">isPrimary</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t148" class="mis show_mis"><span class="n"><a href="#t148">148</a></span><span class="t">            <span class="nam">flash</span><span class="op">(</span><span class="str">'&#24744;&#24050;&#25104;&#21151;&#36864;&#36873;&#35813;&#35838;&#31243;&#65281;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t149" class="pln"><span class="n"><a href="#t149">149</a></span><span class="t">        <span class="key">else</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t150" class="mis show_mis"><span class="n"><a href="#t150">150</a></span><span class="t">            <span class="nam">flash</span><span class="op">(</span><span class="str">'&#24744;&#24050;&#25104;&#21151;&#23558;&#35813;&#35838;&#31227;&#20986;&#22791;&#36873;&#65281;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t151" class="mis show_mis"><span class="n"><a href="#t151">151</a></span><span class="t">        <span class="key">return</span> <span class="nam">redirect</span><span class="op">(</span><span class="nam">url_for</span><span class="op">(</span><span class="str">'std.student_list_courses'</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t152" class="mis show_mis"><span class="n"><a href="#t152">152</a></span><span class="t">    <span class="nam">flash</span><span class="op">(</span><span class="str">'&#35201;&#21024;&#38500;&#30340;&#35838;&#19981;&#23384;&#22312;&#65281;'</span><span class="op">)</span>  <span class="com"># &#27491;&#24120;&#19981;&#20250;&#25191;&#34892;&#21040;&#36825;&#37324;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t153" class="mis show_mis"><span class="n"><a href="#t153">153</a></span><span class="t">    <span class="key">return</span> <span class="nam">redirect</span><span class="op">(</span><span class="nam">url_for</span><span class="op">(</span><span class="str">'std.student_list_courses'</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t154" class="pln"><span class="n"><a href="#t154">154</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t155" class="pln"><span class="n"><a href="#t155">155</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t156" class="run"><span class="n"><a href="#t156">156</a></span><span class="t"><span class="op">@</span><span class="nam">std</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/student-view-report-card'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t157" class="run"><span class="n"><a href="#t157">157</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t158" class="pln"><span class="n"><a href="#t158">158</a></span><span class="t"><span class="key">def</span> <span class="nam">student_view_report_card</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t159" class="pln"><span class="n"><a href="#t159">159</a></span><span class="t">    <span class="com"># &#26412;&#36335;&#30001;&#23637;&#29616;&#25104;&#32489;&#21333;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t160" class="pln"><span class="n"><a href="#t160">160</a></span><span class="t">    <span class="com"># &#36890;&#36807;&#26597;&#35810;Takes&#34920;&#65292;&#24471;&#21040;&#26412;&#23398;&#29983;&#26377;&#25104;&#32489;&#30340;&#35838;&#31243;&#65292;&#36820;&#22238;takes&#23454;&#20363;&#65292;&#20256;&#21040;&#21069;&#31471;&#65292;&#21069;&#31471;&#23637;&#31034;&#35838;&#31243;&#21517;&#21644;&#25104;&#32489;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t161" class="pln"><span class="n"><a href="#t161">161</a></span><span class="t">    <span class="com"># &#26597;&#21040;&#30340;&#35838;&#31243;&#21517;&#21644;&#25104;&#32489;&#35760;&#24405;(&#27604;&#22914;&#20026;takes&#23454;&#20363;)&#22312;&#21015;&#34920; report_card&#37324;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t162" class="mis show_mis"><span class="n"><a href="#t162">162</a></span><span class="t">    <span class="nam">report_card</span> <span class="op">=</span> <span class="nam">Takes</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Takes</span><span class="op">.</span><span class="nam">student_id</span> <span class="op">==</span> <span class="nam">current_user</span><span class="op">.</span><span class="nam">get_id</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Takes</span><span class="op">.</span><span class="nam">isPrimary</span><span class="op">)</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span>&nbsp;</span><span class="r"></span></p>
    <p id="t163" class="pln"><span class="n"><a href="#t163">163</a></span><span class="t">       <span class="key">not</span> <span class="nam">Takes</span><span class="op">.</span><span class="nam">grade</span><span class="op">)</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t164" class="mis show_mis"><span class="n"><a href="#t164">164</a></span><span class="t">    <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'student/student_view_report_card.html'</span><span class="op">,</span> <span class="nam">report_card</span><span class="op">=</span><span class="nam">report_card</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t165" class="pln"><span class="n"><a href="#t165">165</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t166" class="pln"><span class="n"><a href="#t166">166</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t167" class="run"><span class="n"><a href="#t167">167</a></span><span class="t"><span class="op">@</span><span class="nam">std</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/student-input-box'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t168" class="run"><span class="n"><a href="#t168">168</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t169" class="pln"><span class="n"><a href="#t169">169</a></span><span class="t"><span class="key">def</span> <span class="nam">student_input_box</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t170" class="pln"><span class="n"><a href="#t170">170</a></span><span class="t">    <span class="com"># &#33719;&#21462;&#28040;&#24687;&#21015;&#34920;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t171" class="pln"><span class="n"><a href="#t171">171</a></span><span class="t">    <span class="com"># &#26597;&#35810;input_box&#20013;id=current_user.get_id()&#30340;&#28040;&#24687;&#65292;&#25353;&#26102;&#38388;&#25490;&#24207;(&#26368;&#22909;&#25490;&#24207;)&#65292;&#24182;&#26681;&#25454;hasBeenRead&#20998;&#25104;&#24050;&#35835;&#28040;&#24687;&#21644;&#26410;&#35835;&#28040;&#24687;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t172" class="pln"><span class="n"><a href="#t172">172</a></span><span class="t">    <span class="com"># &#24050;&#35835;&#28040;&#24687; old_messages&#65292;&#26410;&#35835;&#28040;&#24687; new_messages&#65292;&#22914;&#26524;new_messages&#20026;&#31354;&#65292;&#21017;&#32622;hasUnreadMessages=True&#65292;&#36825;&#20010;&#21442;&#25968;&#29992;&#20110;&#20915;&#23450;&#39068;&#33394;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t173" class="mis show_mis"><span class="n"><a href="#t173">173</a></span><span class="t">    <span class="nam">old_messages</span> <span class="op">=</span> <span class="nam">Inputbox</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Inputbox</span><span class="op">.</span><span class="nam">user_id</span> <span class="op">==</span> <span class="nam">current_user</span><span class="op">.</span><span class="nam">get_id</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span>&nbsp;</span><span class="r"></span></p>
    <p id="t174" class="pln"><span class="n"><a href="#t174">174</a></span><span class="t">        <span class="nam">Inputbox</span><span class="op">.</span><span class="nam">hasBeenRead</span> <span class="op">==</span> <span class="key">True</span><span class="op">)</span><span class="op">.</span><span class="nam">order_by</span><span class="op">(</span><span class="nam">Inputbox</span><span class="op">.</span><span class="nam">timestamp</span><span class="op">.</span><span class="nam">desc</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t175" class="mis show_mis"><span class="n"><a href="#t175">175</a></span><span class="t">    <span class="nam">new_messages</span> <span class="op">=</span> <span class="nam">Inputbox</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Inputbox</span><span class="op">.</span><span class="nam">user_id</span> <span class="op">==</span> <span class="nam">current_user</span><span class="op">.</span><span class="nam">get_id</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span>&nbsp;</span><span class="r"></span></p>
    <p id="t176" class="pln"><span class="n"><a href="#t176">176</a></span><span class="t">        <span class="nam">Inputbox</span><span class="op">.</span><span class="nam">hasBeenRead</span> <span class="op">==</span> <span class="key">False</span><span class="op">)</span><span class="op">.</span><span class="nam">order_by</span><span class="op">(</span><span class="nam">Inputbox</span><span class="op">.</span><span class="nam">timestamp</span><span class="op">.</span><span class="nam">desc</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t177" class="mis show_mis"><span class="n"><a href="#t177">177</a></span><span class="t">    <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'student/student_input_box.html'</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t178" class="pln"><span class="n"><a href="#t178">178</a></span><span class="t">                           <span class="nam">old_messages</span><span class="op">=</span><span class="nam">old_messages</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t179" class="pln"><span class="n"><a href="#t179">179</a></span><span class="t">                           <span class="nam">new_messages</span><span class="op">=</span><span class="nam">new_messages</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t180" class="pln"><span class="n"><a href="#t180">180</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t181" class="pln"><span class="n"><a href="#t181">181</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t182" class="pln"><span class="n"><a href="#t182">182</a></span><span class="t"><span class="com"># input_box&#30340;&#36741;&#21161;&#36335;&#30001;&#65292;&#20165;&#22788;&#29702;&#25968;&#25454;&#65292;&#26080;&#23454;&#38469;&#30028;&#38754;&#65292;&#25968;&#25454;&#22788;&#29702;&#23436;&#25104;&#21518;&#22238;&#21040;input_box&#30028;&#38754;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t183" class="run"><span class="n"><a href="#t183">183</a></span><span class="t"><span class="op">@</span><span class="nam">std</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/student-mark-all_messages_as_read'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t184" class="run"><span class="n"><a href="#t184">184</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t185" class="pln"><span class="n"><a href="#t185">185</a></span><span class="t"><span class="key">def</span> <span class="nam">student_mark_all_messages_as_read</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t186" class="pln"><span class="n"><a href="#t186">186</a></span><span class="t">    <span class="com"># &#26412;&#36335;&#30001;&#23558;&#35813;&#23398;&#29983;&#25152;&#26377;&#26410;&#35835;&#28040;&#24687;&#26631;&#35760;&#20026;&#24050;&#35835;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t187" class="pln"><span class="n"><a href="#t187">187</a></span><span class="t">    <span class="com"># &#20462;&#25913;&#25968;&#25454;&#24211;&#65292;&#23558;input_box&#37324;&#30340;&#25152;&#26377;id=current_user.get_id()&#30340;&#28040;&#24687;&#30340;hasBeenRead&#39033;&#30446;&#32622;&#20026;True</span>&nbsp;</span><span class="r"></span></p>
    <p id="t188" class="pln"><span class="n"><a href="#t188">188</a></span><span class="t">    <span class="com"># &#28982;&#21518;&#36820;&#22238;input-box</span>&nbsp;</span><span class="r"></span></p>
    <p id="t189" class="mis show_mis"><span class="n"><a href="#t189">189</a></span><span class="t">    <span class="nam">inputbox</span> <span class="op">=</span> <span class="nam">Inputbox</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Inputbox</span><span class="op">.</span><span class="nam">user_id</span> <span class="op">==</span> <span class="nam">current_user</span><span class="op">.</span><span class="nam">get_id</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span>&nbsp;</span><span class="r"></span></p>
    <p id="t190" class="pln"><span class="n"><a href="#t190">190</a></span><span class="t">        <span class="nam">Inputbox</span><span class="op">.</span><span class="nam">hasBeenRead</span> <span class="op">==</span> <span class="key">False</span><span class="op">)</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t191" class="mis show_mis"><span class="n"><a href="#t191">191</a></span><span class="t">    <span class="key">for</span> <span class="nam">i</span> <span class="key">in</span> <span class="nam">range</span><span class="op">(</span><span class="nam">len</span><span class="op">(</span><span class="nam">inputbox</span><span class="op">)</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t192" class="mis show_mis"><span class="n"><a href="#t192">192</a></span><span class="t">        <span class="nam">inputbox</span><span class="op">[</span><span class="nam">i</span><span class="op">]</span><span class="op">.</span><span class="nam">hasBeenRead</span> <span class="op">=</span> <span class="key">True</span>&nbsp;</span><span class="r"></span></p>
    <p id="t193" class="mis show_mis"><span class="n"><a href="#t193">193</a></span><span class="t">    <span class="key">return</span> <span class="nam">redirect</span><span class="op">(</span><span class="nam">url_for</span><span class="op">(</span><span class="str">'std.student_input_box'</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t194" class="pln"><span class="n"><a href="#t194">194</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t195" class="pln"><span class="n"><a href="#t195">195</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t196" class="run"><span class="n"><a href="#t196">196</a></span><span class="t"><span class="op">@</span><span class="nam">std</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/student-bill-information'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t197" class="run"><span class="n"><a href="#t197">197</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t198" class="pln"><span class="n"><a href="#t198">198</a></span><span class="t"><span class="key">def</span> <span class="nam">student_bill_information</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t199" class="pln"><span class="n"><a href="#t199">199</a></span><span class="t">    <span class="com"># &#26412;&#36335;&#30001;&#36134;&#21333;&#30028;&#38754;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t200" class="pln"><span class="n"><a href="#t200">200</a></span><span class="t">    <span class="com"># &#26597;&#25968;&#25454;&#24211;&#65292;&#26597;&#20986;&#26412;&#23398;&#29983;&#26410;&#25903;&#20184;&#30340;&#35838;&#31243;&#21517;&#23383;&#21450;&#20854;&#20215;&#26684;&#65292;&#35745;&#31639;&#20986;&#21512;&#35745;&#38656;&#35201;&#25903;&#20184;&#30340;&#37329;&#39069;&#65292;&#20197;&#21450;&#26412;&#23398;&#29983;&#30340;balance</span>&nbsp;</span><span class="r"></span></p>
    <p id="t201" class="pln"><span class="n"><a href="#t201">201</a></span><span class="t">    <span class="com"># &#26412;&#36335;&#30001;&#20165;&#26597;&#35810;&#65292;&#23558;&#32467;&#26524;&#36820;&#22238;&#21040;&#21069;&#31471;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t202" class="mis show_mis"><span class="n"><a href="#t202">202</a></span><span class="t">    <span class="nam">bill</span> <span class="op">=</span> <span class="nam">Bill</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Bill</span><span class="op">.</span><span class="nam">bill_id</span> <span class="op">==</span> <span class="nam">current_user</span><span class="op">.</span><span class="nam">get_id</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t203" class="mis show_mis"><span class="n"><a href="#t203">203</a></span><span class="t">    <span class="nam">balance</span> <span class="op">=</span> <span class="nam">Student</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Student</span><span class="op">.</span><span class="nam">student_id</span><span class="op">==</span><span class="nam">current_user</span><span class="op">.</span><span class="nam">get_id</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="nam">first</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">balance</span>&nbsp;</span><span class="r"></span></p>
    <p id="t204" class="mis show_mis"><span class="n"><a href="#t204">204</a></span><span class="t">    <span class="nam">items</span> <span class="op">=</span> <span class="op">[</span><span class="op">[</span><span class="nam">b</span><span class="op">.</span><span class="nam">course</span><span class="op">.</span><span class="nam">course_name</span><span class="op">,</span> <span class="nam">b</span><span class="op">.</span><span class="nam">course_price</span><span class="op">]</span> <span class="key">for</span> <span class="nam">b</span> <span class="key">in</span> <span class="nam">bill</span><span class="op">]</span>  <span class="com"># &#21015;&#34920;&#65292;&#27599;&#19968;&#39033;&#30001;&#35838;&#31243;&#21517;&#21644;&#35838;&#31243;&#37329;&#39069;&#26500;&#25104;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t205" class="mis show_mis"><span class="n"><a href="#t205">205</a></span><span class="t">    <span class="nam">total</span> <span class="op">=</span> <span class="nam">sum</span><span class="op">(</span><span class="op">[</span><span class="nam">b</span><span class="op">.</span><span class="nam">course_price</span> <span class="key">for</span> <span class="nam">b</span> <span class="key">in</span> <span class="nam">bill</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t206" class="mis show_mis"><span class="n"><a href="#t206">206</a></span><span class="t">    <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'student/student_bill_information.html'</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t207" class="pln"><span class="n"><a href="#t207">207</a></span><span class="t">                           <span class="nam">items</span><span class="op">=</span><span class="nam">items</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t208" class="pln"><span class="n"><a href="#t208">208</a></span><span class="t">                           <span class="nam">balance</span><span class="op">=</span><span class="nam">balance</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t209" class="pln"><span class="n"><a href="#t209">209</a></span><span class="t">                           <span class="nam">total</span><span class="op">=</span><span class="nam">total</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t210" class="pln"><span class="n"><a href="#t210">210</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t211" class="pln"><span class="n"><a href="#t211">211</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t212" class="run"><span class="n"><a href="#t212">212</a></span><span class="t"><span class="op">@</span><span class="nam">std</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/student-deposit'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t213" class="run"><span class="n"><a href="#t213">213</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t214" class="pln"><span class="n"><a href="#t214">214</a></span><span class="t"><span class="key">def</span> <span class="nam">student_deposit</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t215" class="pln"><span class="n"><a href="#t215">215</a></span><span class="t">    <span class="com"># &#23398;&#29983;&#20805;&#20540;&#65292;&#26412;&#36335;&#30001;&#38656;&#35201;&#23398;&#29983;&#22635;&#20889;&#34920;&#21333;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t216" class="pln"><span class="n"><a href="#t216">216</a></span><span class="t">    <span class="com"># &#33509;&#20805;&#20540;&#25104;&#21151;&#65292;&#21017;&#36820;&#22238;std.student_bill_information&#65292;&#21542;&#21017;&#20572;&#30041;&#22312;&#36825;&#20010;&#39029;&#38754;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t217" class="mis show_mis"><span class="n"><a href="#t217">217</a></span><span class="t">    <span class="nam">depositForm</span> <span class="op">=</span> <span class="nam">DepositForm</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t218" class="mis show_mis"><span class="n"><a href="#t218">218</a></span><span class="t">    <span class="key">if</span> <span class="nam">depositForm</span><span class="op">.</span><span class="nam">validate_on_submit</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t219" class="mis show_mis"><span class="n"><a href="#t219">219</a></span><span class="t">        <span class="key">if</span> <span class="nam">depositForm</span><span class="op">.</span><span class="nam">amount</span><span class="op">.</span><span class="nam">data</span> <span class="op">&lt;=</span> <span class="num">0</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t220" class="mis show_mis"><span class="n"><a href="#t220">220</a></span><span class="t">            <span class="nam">flash</span><span class="op">(</span><span class="str">"&#35831;&#36755;&#20837;&#27491;&#30830;&#30340;&#37329;&#39069;"</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t221" class="mis show_mis"><span class="n"><a href="#t221">221</a></span><span class="t">            <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'student/student_deposit.html'</span><span class="op">,</span> <span class="nam">form</span><span class="op">=</span><span class="nam">depositForm</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t222" class="mis show_mis"><span class="n"><a href="#t222">222</a></span><span class="t">        <span class="nam">student</span> <span class="op">=</span> <span class="nam">Student</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Student</span><span class="op">.</span><span class="nam">student_id</span> <span class="op">==</span> <span class="nam">current_user</span><span class="op">.</span><span class="nam">get_id</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="nam">first</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t223" class="mis show_mis"><span class="n"><a href="#t223">223</a></span><span class="t">        <span class="nam">student</span><span class="op">.</span><span class="nam">balance</span> <span class="op">+=</span> <span class="nam">depositForm</span><span class="op">.</span><span class="nam">amount</span><span class="op">.</span><span class="nam">data</span>&nbsp;</span><span class="r"></span></p>
    <p id="t224" class="mis show_mis"><span class="n"><a href="#t224">224</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">add</span><span class="op">(</span><span class="nam">student</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t225" class="mis show_mis"><span class="n"><a href="#t225">225</a></span><span class="t">        <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">commit</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t226" class="mis show_mis"><span class="n"><a href="#t226">226</a></span><span class="t">        <span class="nam">flash</span><span class="op">(</span><span class="str">'&#20805;&#20540;&#25104;&#21151;&#65281;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t227" class="mis show_mis"><span class="n"><a href="#t227">227</a></span><span class="t">        <span class="key">return</span> <span class="nam">redirect</span><span class="op">(</span><span class="nam">url_for</span><span class="op">(</span><span class="str">'std.student_bill_information'</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t228" class="mis show_mis"><span class="n"><a href="#t228">228</a></span><span class="t">    <span class="key">return</span> <span class="nam">render_template</span><span class="op">(</span><span class="str">'student/student_deposit.html'</span><span class="op">,</span> <span class="nam">form</span><span class="op">=</span><span class="nam">depositForm</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t229" class="pln"><span class="n"><a href="#t229">229</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t230" class="pln"><span class="n"><a href="#t230">230</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t231" class="run"><span class="n"><a href="#t231">231</a></span><span class="t"><span class="op">@</span><span class="nam">std</span><span class="op">.</span><span class="nam">route</span><span class="op">(</span><span class="str">'/student-pay/&lt;total>'</span><span class="op">,</span> <span class="nam">methods</span><span class="op">=</span><span class="op">[</span><span class="str">'GET'</span><span class="op">,</span> <span class="str">'POST'</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t232" class="run"><span class="n"><a href="#t232">232</a></span><span class="t"><span class="op">@</span><span class="nam">login_required</span>&nbsp;</span><span class="r"></span></p>
    <p id="t233" class="pln"><span class="n"><a href="#t233">233</a></span><span class="t"><span class="key">def</span> <span class="nam">student_pay</span><span class="op">(</span><span class="nam">total</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t234" class="pln"><span class="n"><a href="#t234">234</a></span><span class="t">    <span class="com"># &#26412;&#36335;&#30001;&#29992;&#20110;&#23398;&#29983;&#25903;&#20184;&#23398;&#36153;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t235" class="pln"><span class="n"><a href="#t235">235</a></span><span class="t">    <span class="com"># &#36825;&#37324;&#35268;&#23450;&#65292;&#23398;&#29983;&#22312;&#25903;&#20184;&#26102;&#65292;&#38656;&#35201;&#20445;&#35777;&#20313;&#39069;&#19981;&#23567;&#20110;&#38656;&#25903;&#20184;&#30340;&#24635;&#37329;&#39069;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t236" class="pln"><span class="n"><a href="#t236">236</a></span><span class="t">    <span class="com"># &#23398;&#29983;&#21482;&#33021;&#19968;&#27425;&#25903;&#20184;&#23436;&#25152;&#26377;&#26410;&#25903;&#20184;&#35838;&#31243;&#30340;&#24635;&#37329;&#39069;&#65292;&#32780;&#19981;&#33021;&#36873;&#25321;&#37096;&#20998;&#35838;&#31243;&#25903;&#20184;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t237" class="mis show_mis"><span class="n"><a href="#t237">237</a></span><span class="t">    <span class="nam">student</span> <span class="op">=</span> <span class="nam">Student</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Student</span><span class="op">.</span><span class="nam">student_id</span> <span class="op">==</span> <span class="nam">current_user</span><span class="op">.</span><span class="nam">get_id</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="nam">first</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t238" class="mis show_mis"><span class="n"><a href="#t238">238</a></span><span class="t">    <span class="key">if</span> <span class="nam">student</span><span class="op">.</span><span class="nam">balance</span> <span class="op">&lt;</span> <span class="nam">total</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t239" class="mis show_mis"><span class="n"><a href="#t239">239</a></span><span class="t">        <span class="nam">flash</span><span class="op">(</span><span class="str">'&#24403;&#21069;&#20313;&#39069;&#19981;&#36275;&#65292;&#35831;&#20805;&#20540;&#65281;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t240" class="pln"><span class="n"><a href="#t240">240</a></span><span class="t">        <span class="com"># &#25903;&#20184;&#22833;&#36133;&#65292;&#37329;&#39069;&#19981;&#36275;&#65292;&#33258;&#21160;&#36339;&#36716;&#21040;&#20805;&#20540;&#39029;&#38754;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t241" class="mis show_mis"><span class="n"><a href="#t241">241</a></span><span class="t">        <span class="key">return</span> <span class="nam">redirect</span><span class="op">(</span><span class="nam">url_for</span><span class="op">(</span><span class="str">'std.student_deposit'</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t242" class="pln"><span class="n"><a href="#t242">242</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t243" class="mis show_mis"><span class="n"><a href="#t243">243</a></span><span class="t">    <span class="nam">student</span><span class="op">.</span><span class="nam">balance</span> <span class="op">-=</span> <span class="nam">total</span>  <span class="com"># &#23558;&#23398;&#29983;&#37329;&#39069;&#25187;&#38500;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t244" class="mis show_mis"><span class="n"><a href="#t244">244</a></span><span class="t">    <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">add</span><span class="op">(</span><span class="nam">student</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t245" class="mis show_mis"><span class="n"><a href="#t245">245</a></span><span class="t">    <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">commit</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t246" class="pln"><span class="n"><a href="#t246">246</a></span><span class="t">    <span class="com"># &#32622;hasBeenPaid=True&#25805;&#20316;&#24050;&#20462;&#25913;</span>&nbsp;</span><span class="r"></span></p>
    <p id="t247" class="mis show_mis"><span class="n"><a href="#t247">247</a></span><span class="t">    <span class="nam">bill</span> <span class="op">=</span> <span class="nam">Bill</span><span class="op">.</span><span class="nam">query</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Bill</span><span class="op">.</span><span class="nam">bill_id</span> <span class="op">==</span> <span class="nam">current_user</span><span class="op">.</span><span class="nam">get_id</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="nam">filter</span><span class="op">(</span><span class="nam">Bill</span><span class="op">.</span><span class="nam">hasBeenPaid</span> <span class="op">==</span> <span class="key">False</span><span class="op">)</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t248" class="mis show_mis"><span class="n"><a href="#t248">248</a></span><span class="t">    <span class="key">for</span> <span class="nam">i</span> <span class="key">in</span> <span class="nam">range</span><span class="op">(</span><span class="nam">len</span><span class="op">(</span><span class="nam">bill</span><span class="op">)</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t249" class="mis show_mis"><span class="n"><a href="#t249">249</a></span><span class="t">        <span class="nam">bill</span><span class="op">[</span><span class="nam">i</span><span class="op">]</span><span class="op">.</span><span class="nam">hasBeenPaid</span> <span class="op">=</span> <span class="key">True</span>&nbsp;</span><span class="r"></span></p>
    <p id="t250" class="mis show_mis"><span class="n"><a href="#t250">250</a></span><span class="t">    <span class="nam">db</span><span class="op">.</span><span class="nam">session</span><span class="op">.</span><span class="nam">commit</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t251" class="pln"><span class="n"><a href="#t251">251</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t252" class="mis show_mis"><span class="n"><a href="#t252">252</a></span><span class="t">    <span class="nam">flash</span><span class="op">(</span><span class="str">'&#25903;&#20184;&#23436;&#25104;&#65281;'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t253" class="pln"><span class="n"><a href="#t253">253</a></span><span class="t">    <span class="com"># &#25903;&#20184;&#25104;&#21151;&#21518;&#65292;&#36820;&#22238;std.student_bill_information</span>&nbsp;</span><span class="r"></span></p>
    <p id="t254" class="mis show_mis"><span class="n"><a href="#t254">254</a></span><span class="t">    <span class="key">return</span> <span class="nam">redirect</span><span class="op">(</span><span class="nam">url_for</span><span class="op">(</span><span class="str">'std.student_bill_information'</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
</div>
<div id="footer">
    <div class="content">
        <p>
            <a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v5.1</a>,
            created at 2020-06-08 16:42
        </p>
    </div>
</div>
</body>
</html>
